﻿<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title>工序基础数据上传</title>
  <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
  <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
  <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
  <link rel="stylesheet" href="/InSiteWebApplication/Content/webuploader/webuploader.css" />
  <style type="text/css">
    .webuploader-pick {
      position: relative;
      display: inline-block;
      cursor: pointer;
      background: #00b7ee;
      padding: 5px 15px;
      color: #fff;
      text-align: center;
      overflow: hidden;
      font-size: 15px;
    }

    #temUploader .webuploader-pick {
      width: 200px;
    }
  </style>
</head>

<body>
  <div>
    <div class="ufcSectionStyle">
      <span class="ufcSectionSpanStyle">模板选择</span>
    </div>
    <div style="margin: 3px 0px 3px 3px">
      <div style="float: left; margin-left: 10px">
        <div class="divLabel" style="margin-bottom: 5px">
          模板：</div>
        <select style='width: 180px; height: 20px' id='selFileStatus' data-options='editable:false,panelHeight:80'
          class='easyui-combobox'>
          <!--                    <option value="0" selected>工序生产周期模板</option>
                    <option value="1">工序设备模板</option>-->
        </select>
      </div>
    </div>
    <div style="clear: both">
    </div>
    <div class="ufcSectionStyle">
      <span class="ufcSectionSpanStyle">导入区域</span>
    </div>
    <div style="margin: 3px 0px 3px 3px">
      <div class="divLabel">
        选择导入Excel文件：</div>
      <div id="uploader" style="margin-top: 5px" class="wu-example">
        <div style="float: left">
          <input id="txtExcelFileName" class="easyui-textbox" type="text" style="width: 200px;
                        height: 22px; float: left;" readonly="readonly" />
          <input id="txtExcelFileId" type="hidden" />
        </div>
        <div style="float: left" class="btns">
          <div id="picker" style="float: left; margin-left: 5px; margin-top: -8px;">
            选择文件</div>
          <button id="ctlBtn" class="easyui-linkbutton" style="float: left; margin-left: 5px;
                        margin-top: -3px; height: 26px; width: 80px;">
            上传</button>
          <a href="/InSiteWebApplication/Temp2/导入模板/工序生产周期导入模板.xlsx" class="easyui-linkbutton" style="margin:-3px 0 0 5px;height: 26px;">模板下载</a>
          <span style="color:red;font-weight:bold;margin-left: 10px;">内部系统，禁止处理涉密信息！</span>
        </div>
      </div>
    </div>
    <div style="clear: both">
    </div>
    <div id="statusMessage" style="font-size: 14px; height: 40px">
    </div>
  </div>
</body>

</html>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script type="text/javascript" src="/InSiteWebApplication/Content/webuploader/webuploader.js"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
  var page = {
    rootPath: getRootPath(), //网站根路径
    type: "0",
    init: function () {
      $('#picker').css("padding", "5px 10px"); //改变上传按钮样式
      page.uploadExcel();
      //            $(document).ready(function () {
      //                $("#selFileStatus").combobox({
      //                    valueField: 'value',
      //                    textField: 'name',
      //                    panelHeight: 200,
      //                    data: [{ value: "0", name: "工序生产周期模板" }, { value: "1", name: "工序设备模板"}],
      //                    onSelect: function (record) {
      //                        page.type = record.value;
      //                        page.uploadExcel();
      //                    }
      //                });
      //            });
    },
    //上传excel
    uploadExcel: function () {
      var uploader = WebUploader.create({
        // swf文件路径
        swf: page.rootPath + "/Content/webuploader/Uploader.swf",
        // 文件接收服务端。
        server: page.rootPath + '/Ashx/ApsHandler/ApsBaseDataUpdateHandler.ashx',
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#picker',
        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false,
        formData: {
          action: "UpdateStepBaseData",
          modelType: page.type
        },
        accept: {
          title: 'Excel',
          extensions: 'xlsx,xls',
          mimeTypes: 'excel/*'
        },
        multiple: false,
        timeout: 10 * 60 * 1000
      });
      //上传
      $('#ctlBtn').on("click", function () {
        var filename = $('#txtExcelFileName').textbox('getValue');
        if (filename == "") {
          displayMessage("未选择文件", false);
        } else {
          $('#ctlBtn').attr("disabled", "disabled"); //禁用按钮
          $.messager.progress({ text: '', msg: '处理中...' });
          uploader.upload();
        }
      });
      // 当有文件被添加进队列的时候，每次只传一个文件
      uploader.on('fileQueued', function (file) {
        if ($('#txtExcelFileId').val() != "") {
          var f = uploader.getFile($('#txtExcelFileId').val()); //找到上一次队列中的文件
          uploader.removeFile(f, true); //删除掉上一次队列中的文件
        }
        $('#txtExcelFileName').textbox('setValue', file.name);
        $('#txtExcelFileId').val(file.id);
      });
      //上传成功
      uploader.on('uploadSuccess', function (file, response) {
        displayMessage("", true);
        $.messager.progress('close');
        var result = response;
        displayMessage(result.Message, result.Result);
        var f = uploader.getFile(file.id); //找到上传的文件
        uploader.removeFile(f, true); //将其从队列中的删掉
        $('#txtExcelFileName').textbox('setValue', "");
        $('#txtExcelFileId').val("");
        $('#ctlBtn').removeAttr("disabled"); //恢复按钮
      });
      //上传失败
      uploader.on('uploadError', function (file, reason) {
        $.messager.progress('close');
        displayMessage("上传失败，原因：" + reason, false);
        var f = uploader.getFile(file.id); //找到上传的文件
        uploader.removeFile(f, true); //将其从队列中的删掉
        $('#txtExcelFileName').textbox('setValue', "");
        $('#txtExcelFileId').val("");
        $('#ctlBtn').removeAttr("disabled"); //恢复按钮
      });
    }
  };
  page.init();
</script>